package com.gitee.wsl.markdown.plugin

import com.gitee.wsl.markdown.Markwon
import com.gitee.wsl.markdown.MarkwonModelPluginBuilder
import com.gitee.wsl.markdown.MarkwonModelPluginInstance
import com.gitee.wsl.model.plugin.ModelPlugin
import com.gitee.wsl.model.plugin.createPlugin

typealias MarkwonPlugin<PluginConfig,TPlugin> = ModelPlugin<Markwon, PluginConfig, TPlugin>

fun createMarkwonPlugin(
    name: String,
    body: MarkwonModelPluginBuilder<Unit>.() -> Unit
) = createMarkwonPlugin(name, {}, body)


fun <PluginConfigT> createMarkwonPlugin(
    name: String,
    createConfiguration: () -> PluginConfigT,
    body: MarkwonModelPluginBuilder<PluginConfigT>.() -> Unit
) = createPlugin<Markwon,PluginConfigT, MarkwonModelPluginBuilder<PluginConfigT>, MarkwonModelPluginInstance<PluginConfigT>>(name,
    createConfiguration,
    createModelPluginInstance = { key, configT, body1 -> MarkwonModelPluginInstance(key,configT,body1) },
    body)